﻿using KayakMes.Common.Dtos.ProductControlDTO.Input;
using KayakMes.Common.Result;
using KayakMes.ProductControl.Application.Services;
using KayakMes.ProductControl.Domain.Entity;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace KayakMes.ProductControl.API.Controllers
{
    /// <summary>
    /// 产品管理—型号控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class TypeController : ControllerBase
    {
        private readonly IProductService productService;

        public TypeController(IProductService productService)
        {
            this.productService = productService;
        }
        /// <summary>
        /// 添加型号信息
        /// </summary>
        /// <param name="product">产品实体</param>
        /// <returns>返回受影响行数</returns>
        [HttpPost]
        public ApiResult<int> AddType(TypeModel type)
        {
            return productService.AddType(type);
        }
        /// <summary>
        /// 获取所有型号信息
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        [HttpGet]
        public ApiPaging<TypeModel> GetAllType([FromQuery]TypeDto dto)
        {
            return productService.GetAllType(dto);
        }
        /// <summary>
        /// 获取指定型号信息
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        [HttpGet]
        public ApiResult<TypeModel> GetType([FromQuery] long Id)
        {
            return productService.GetType(Id);
        }
        /// <summary>
        /// 删除指定型号信息
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        [HttpDelete]
        public ApiResult<int> DelType(long Id)
        {
            return productService.DelType(Id);
        }
        /// <summary>
        /// 修改型号信息
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        [HttpPut]
        public ApiResult<int> UpdateType(TypeModel type)
        {
            return productService.UpdateType(type);
        }
    }
}
